package com.shopping.adminServlet;

import java.io.IOException;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.shopping.bean.OrderGoods;
import com.shopping.bean.Page;
import com.shopping.service.OrderGoodsService;
import com.shopping.service.impl.OrderGoodsServiceImpl;

/**
 * @author 216
 *	后台获取订单
 */
@WebServlet("/getOrderGoods.do")
public class AdminServletGetOrderGoods extends HttpServlet{

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		Map<String,String[]> map = req.getParameterMap();
		
		OrderGoodsService ogd = new OrderGoodsServiceImpl();
		
		Page<OrderGoods> page = ogd.findAll(map);
		ObjectMapper om = new ObjectMapper();
		resp.setCharacterEncoding("UTF-8");
		resp.setContentType("application/json");
		resp.getWriter().print(om.writeValueAsString(page));	
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doGet(req,resp);
	}

}
